import { deepCopy } from '@delon/util'
import { Injectable } from '@angular/core'

import { RiskControlRule } from '@shared/interfaces/risk-control'
import { ObservableStore } from '@shared/classes/ObservableStoreClass'


@Injectable()
export class RiskRuleStoreService extends ObservableStore<RiskControlRule> {
  constructor() {
    super(new RiskControlRule())
  }

  updateValue(riskControlRule: RiskControlRule): void {
    const value = deepCopy(this.value)
    Object.assign(value, riskControlRule)
    this.setValue(value)
  }

  reset(): void {
    this.setValue(new RiskControlRule())
  }
}
